<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"

      xmlns:c="http://java.sun.com/jsp/jstl/core">
    <ui:composition template="/resources/default/template/plantilla.xhtml">

        <ui:define name="head">

            <f:loadBundle basename="company.allocation.label_es"  var="label" />
            <f:loadBundle basename="company.allocation.message_es" var="message" />

            <title><h:outputText value="#{label.title1}"/></title>
        </ui:define>

        <ui:define name="moduleTitle">#{label.title1}</ui:define>

        <ui:define name="autocomplete"><ui:include src="../autocomplete/main.xhtml"/></ui:define>

        <ui:define name="content">
            <p:growl id="messages" showDetail="true"/>
            <h:form>

                <div class="field">
                    <h:outputLabel for="gps" value="#{label.field1}" class="label"/>
                    <h:selectOneMenu id="gps" value="#{company_allocation.gpsBeans.id}" required="#{param['required']=='true'}" requiredMessage="#{message.m23}">
                        <f:selectItems value="#{company_allocation.GPSItemsList}"/>  
                    </h:selectOneMenu>
                </div>

                <div class="field">
                    <h:outputLabel for="compania" value="#{label.field2}" class="label"/>
                    <h:selectOneMenu id="compania" value="#{company_allocation.companyBeans.id}" required="#{param['required']=='true'}" requiredMessage="#{message.m23}">
                        <f:selectItems value="#{company_allocation.companyItemsList}"/>  
                    </h:selectOneMenu>
                </div>

                <!--INSERTAR -->
                <h:commandButton value="#{label.button1}" class="button" actionListener="#{company_allocation.insert()}" onclick="return verificar('#{message.m7}')">
                    <f:param name="required" value="true"/>
                </h:commandButton>

            </h:form>

            <h:form>
                <h4><h:outputText value="#{label.title2}" rendered="#{empty list and logged.masterId == 0}" /></h4>
                <c:set var="list" value="#{company_allocation.listTable()}"/>
                <h:panelGroup layout="block" class="tableWrapper" rendered="#{not empty list and logged.masterId != 0}">
                    <h:dataTable var="p" value="#{list}" class="dataTable">
                        <h:column >
                            <h:selectBooleanCheckbox value="#{company_allocation.checked[p.gpsBeans.id]}"  />
                        </h:column>
                        <h:column >
                            <f:facet name="header">#{label.field3}</f:facet>
                            <h:outputText value="#{p.gpsBeans.imei}"/>
                        </h:column>
                        <h:column >
                            <f:facet name="header">#{label.field4}</f:facet>
                            <h:outputText value="#{p.gpsBeans.marca}"/>
                        </h:column>
                        <h:column >
                            <f:facet name="header">#{label.field5}</f:facet>
                            <h:outputText value="#{p.gpsBeans.modelo}"/>
                        </h:column>
                        <h:column >
                            <f:facet name="header">#{label.field6}</f:facet>
                            <h:outputText value="#{p.companyBeans.nombre}"/>
                        </h:column>
                        <h:column >
                            <f:facet name="header">#{label.field7}</f:facet>
                            <h:outputText value="#{p.gpsBeans.caducidad}" />
                        </h:column>
                     <h:column>
                            <f:facet name="header">#{label.field8}</f:facet>
                            <h:outputLabel   value="#{company_allocation.state[p.id]}" class="label"   />
                        </h:column>
                 
                    </h:dataTable>

                    <!--INSERTAR -->
                    <h:commandButton value="#{label.button2}" class="button" actionListener="#{company_allocation.updateTable()}" onclick="return verificar('#{message.m7}')">
                        <f:param name="required" value="true"/>
                    </h:commandButton>

                </h:panelGroup>                
            </h:form>  
        </ui:define>

    </ui:composition>
</html>
